package com.jdcjk.chat.view;

import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;

import com.jdcjk.MainApp;
import com.jdcjk.R;
import com.jdcjk.project.login.view.LoginActivity;

/**
 * Created by Administrator on 2017/1/16 0016.
 */

public class AccountOfflineDialog extends DialogFragment {
    private View.OnClickListener onClickListener;

    public AccountOfflineDialog() {

    }

    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View viewContent = inflater.inflate(R.layout.dialog_account_offline, container, false);
        //去掉dialog默认标题
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        //取消button
        Button cancl_button = (Button) viewContent.findViewById(R.id.dialog_account_offline_cancle_btn);
        cancl_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //退出账号返回登录界面监听
                Intent intent = new Intent(MainApp.getInstance(), LoginActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                MainApp.getInstance().startActivity(intent);
            }
        });
        //重新登录button
        Button restartLogin_button = (Button) viewContent.findViewById(R.id.dialog_account_offline_restart_login_btn);
        restartLogin_button.setOnClickListener(onClickListener);
        return viewContent;
    }

}
